{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"https://github.com/run-llama/llama_index/blob/main/llama-index-packs/llama-index-packs-cohere-citation-chat/examples/cohere_citation_chat_example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Install and Import Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%pip install llama-index\n",
    "%pip install llama-index-llms-cohere\n",
    "%pip install llama-index-embeddings-cohere\n",
    "%pip install cohere\n",
    "%pip install llama-index-readers-web\n",
    "%pip install llama-index-packs-cohere-citation-chat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "from llama_index.packs.cohere_citation_chat import CohereCitationChatEnginePack\n",
    "from llama_index.readers.web import SimpleWebPageReader"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Configure your Cohere API key."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.environ[\"COHERE_API_KEY\"] = \"your-api-key-here\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Parse your documents and pass to your LlamaPack. In this example, use nodes from a Paul Graham essay as input. Run the LlamaPack to create a chat engine."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "documents = SimpleWebPageReader().load_data(\n",
    "    [\n",
    "        \"https://raw.githubusercontent.com/jerryjliu/llama_index/adb054429f642cc7bbfcb66d4c232e072325eeab/examples/paul_graham_essay/data/paul_graham_essay.txt\"\n",
    "    ]\n",
    ")\n",
    "cohere_citation_chat_pack = CohereCitationChatEnginePack(documents=documents)\n",
    "chat_engine = cohere_citation_chat_pack.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Run a set of queries via the chat engine methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Query \n",
      "=====\n",
      "What did Paul Graham do growing up?\n",
      "Chat\n",
      "Chat Response\n",
      "========\n",
      "Paul Graham grew up in a tiny corner of the Upper East Side of New York, called Yorkville since his family moved from Britain to the United States. He lived in the same apartment from the 1990s and worked hard to make a living. He worked on a new Lisp called Bel, written in Arc, and his friend helped him get an apartment in New York City, where he lived with his family. He wrote a book on Lisp and decided to start a company to put art galleries online, which didn't succeed, and began writing essays about his experiences.\n",
      "Citations: [Citation(text='tiny corner of the Upper East Side of New York', start=25, end=71, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='Yorkville', start=80, end=89, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='Britain to the United States.', start=118, end=147, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='same apartment from the 1990s', start=164, end=193, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='worked hard to make a living.', start=198, end=227, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d', '5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='new Lisp called Bel, written in Arc', start=243, end=278, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='friend helped him get an apartment in New York City', start=288, end=339, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='lived with his family.', start=350, end=372, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='book on Lisp', start=384, end=396, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='start a company to put art galleries online', start=412, end=455, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text=\"didn't succeed\", start=463, end=477, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='writing essays', start=489, end=503, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d', '5ef32917-0965-4551-8359-e8b92557965b'])]\n",
      "Documents: [Document(id='5ef32917-0965-4551-8359-e8b92557965b', text='For example, when you see a painting that looks like a certain kind of cartoon, you know it\\'s by Roy Lichtenstein. So if you see a big painting of this type hanging in the apartment of a hedge fund manager, you know he paid millions of dollars for it. That\\'s not always why artists have a signature style, but it\\'s usually why buyers pay a lot for such work. [6]\\n\\nThere were plenty of earnest students too: kids who \"could draw\" in high school, and now had come to what was supposed to be the best art school in the country, to learn to draw even better. They tended to be confused and demoralized by what they found at RISD, but they kept going, because painting was what they did. I was not one of the kids who could draw in high school, but at RISD I was definitely closer to their tribe than the tribe of signature style seekers.\\n\\nI learned a lot in the color class I took at RISD, but otherwise I was basically teaching myself to paint, and I could do that for free. So in 1993 I dropped out. I hung around Providence for a bit, and then my college friend Nancy Parmet did me a big favor. A rent-controlled apartment in a building her mother owned in New York was becoming vacant. Did I want it? It wasn\\'t much more than my current place, and New York was supposed to be where the artists were. So yes, I wanted it! [7]\\n\\nAsterix comics begin by zooming in on a tiny corner of Roman Gaul that turns out not to be controlled by the Romans. You can do something similar on a map of New York City: if you zoom in on the Upper East Side, there\\'s a tiny corner that\\'s not rich, or at least wasn\\'t in 1993. It\\'s called Yorkville, and that was my new home. Now I was a New York artist — in the strictly technical sense of making paintings and living in New York.\\n\\nI was nervous about money, because I could sense that Interleaf was on the way down. Freelance Lisp hacking work was very rare, and I didn\\'t want to have to program in another language, which in those days would have meant C++ if I was lucky. So with my unerring nose for financial opportunity, I decided to write another book on Lisp. This would be a popular book, the sort of book that could be used as a textbook. I imagined myself living frugally off the royalties and spending all my time painting. (The painting on the cover of this book, ANSI Common Lisp, is one that I painted around this time.)\\n\\nThe best thing about New York for me was the presence of Idelle and Julian Weber. Idelle Weber was a painter, one of the early photorealists, and I\\'d taken her painting class at Harvard. I\\'ve never known a teacher more beloved by her students. Large numbers of former students kept in touch with her, including me. After I moved to New York I became her de facto studio assistant.\\n\\nShe liked to paint on big, square canvases, 4 to 5 feet on a side. One day in late 1994 as I was stretching one of these monsters there was something on the radio about a famous fund manager. He wasn\\'t that much older than me, and was super rich. The thought suddenly occurred to me: why don\\'t I become rich? Then I\\'ll be able to work on whatever I want.\\n\\nMeanwhile I\\'d been hearing more and more about this new thing called the World Wide Web. Robert Morris showed it to me when I visited him in Cambridge, where he was now in grad school at Harvard. It seemed to me that the web would be a big deal. I\\'d seen what graphical user interfaces had done for the popularity of microcomputers. It seemed like the web would do the same for the internet.\\n\\nIf I wanted to get rich, here was the next train leaving the station. I was right about that part. What I got wrong was the idea. I decided we should start a company to put art galleries online. I can\\'t honestly say, after reading so many Y Combinator applications, that this was the worst startup idea ever, but it was up there. Art galleries didn\\'t want to be online, and still don\\'t, not the fancy ones. That\\'s not how they sell. I wrote some software to generate web sites for galleries, and Robert wrote some to resize images and set up an http server to serve the pages. Then we tried to sign up galleries. To call this a difficult sale would be an understatement. It was difficult to give away. A few galleries let us make sites for them for free, but none paid us.'), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d', text='It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it\\'s an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\\n\\nI had to ban myself from writing essays during most of this time, or I\\'d never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you\\'re working on an interpreter written in itself, it\\'s hard to keep track of what\\'s happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it. So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools. It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished. Like McCarthy\\'s original Lisp, it\\'s a spec rather than an implementation, although like McCarthy\\'s Lisp it\\'s a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I\\'d had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who\\'d lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives. So I wrote a more detailed version for others to read, and this is the last sentence of it.\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nNotes\\n\\n[1] My experience skipped a step in the evolution of computers: time-sharing machines with interactive OSes. I went straight from batch processing to microcomputers, which made microcomputers seem all the more exciting.\\n\\n[2] Italian words for abstract concepts can nearly always be predicted from their English cognates (except for occasional traps like polluzione). It\\'s the everyday words that differ. So if you string together a lot of abstract concepts with a few simple verbs, you can make a little Italian go a long way.\\n\\n[3] I lived at Piazza San Felice 4, so my walk to the Accademia went straight down the spine of old Florence: past the Pitti, across the bridge, past Orsanmichele, between the Duomo and the Baptistery, and then up Via Ricasoli to Piazza San Marco. I saw Florence at street level in every possible condition, from empty dark winter evenings to sweltering summer days when the streets were packed with tourists.\\n\\n[4] You can of course paint people like still lives if you want to, and they\\'re willing. That sort of portrait is arguably the apex of still life painting, though the long sitting does tend to produce pained expressions in the sitters.\\n\\n[5] Interleaf was one of many companies that had smart people and built impressive technology, and yet got crushed by Moore\\'s Law. In the 1990s the exponential growth in the power of commodity (i.e.')]\n",
      "Async Chat\n",
      "Async Chat Response\n",
      "========\n",
      "Paul Graham spent his childhood growing up in Yorkville, a tiny corner of the Upper East Side of New York City, after his family moved from Britain to the United States. He lived in the same apartment from the 1990s, and worked hard to make a living. \n",
      "\n",
      "He also worked on a new Lisp called Bel, written in Arc, and learned painting. In 1993, he dropped out of RISD and moved to New York City, where he lived with his family and worked as a studio assistant for Idelle Weber, a painter and early photorealist, whom he had taken a colour class with at Harvard. He worked on Bel intensively and says that it was hard but satisfying work. In 2019, Bel was finally finished and Graham wrote a bunch of essays about topics he had stacked up that he wanted to write about.\n",
      "Citations: [Citation(text='Yorkville', start=46, end=55, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='tiny corner of the Upper East Side of New York City', start=59, end=110, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='lived in the same apartment from the 1990s', start=173, end=215, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='worked hard to make a living.', start=221, end=250, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='new Lisp called Bel, written in Arc', start=273, end=308, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='painting.', start=322, end=331, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='1993', start=335, end=339, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='dropped out of RISD', start=344, end=363, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='moved to New York City', start=368, end=390, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='lived with his family', start=401, end=422, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='studio assistant', start=439, end=455, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='Idelle Weber', start=460, end=472, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='painter', start=476, end=483, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='early photorealist', start=488, end=506, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='colour class with at Harvard.', start=528, end=557, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='intensively', start=575, end=586, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='hard but satisfying work.', start=608, end=633, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='2019', start=637, end=641, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='finished', start=659, end=667, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='wrote a bunch of essays about topics he had stacked up', start=679, end=733, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d'])]\n",
      "Documents: [Document(id='5ef32917-0965-4551-8359-e8b92557965b', text='For example, when you see a painting that looks like a certain kind of cartoon, you know it\\'s by Roy Lichtenstein. So if you see a big painting of this type hanging in the apartment of a hedge fund manager, you know he paid millions of dollars for it. That\\'s not always why artists have a signature style, but it\\'s usually why buyers pay a lot for such work. [6]\\n\\nThere were plenty of earnest students too: kids who \"could draw\" in high school, and now had come to what was supposed to be the best art school in the country, to learn to draw even better. They tended to be confused and demoralized by what they found at RISD, but they kept going, because painting was what they did. I was not one of the kids who could draw in high school, but at RISD I was definitely closer to their tribe than the tribe of signature style seekers.\\n\\nI learned a lot in the color class I took at RISD, but otherwise I was basically teaching myself to paint, and I could do that for free. So in 1993 I dropped out. I hung around Providence for a bit, and then my college friend Nancy Parmet did me a big favor. A rent-controlled apartment in a building her mother owned in New York was becoming vacant. Did I want it? It wasn\\'t much more than my current place, and New York was supposed to be where the artists were. So yes, I wanted it! [7]\\n\\nAsterix comics begin by zooming in on a tiny corner of Roman Gaul that turns out not to be controlled by the Romans. You can do something similar on a map of New York City: if you zoom in on the Upper East Side, there\\'s a tiny corner that\\'s not rich, or at least wasn\\'t in 1993. It\\'s called Yorkville, and that was my new home. Now I was a New York artist — in the strictly technical sense of making paintings and living in New York.\\n\\nI was nervous about money, because I could sense that Interleaf was on the way down. Freelance Lisp hacking work was very rare, and I didn\\'t want to have to program in another language, which in those days would have meant C++ if I was lucky. So with my unerring nose for financial opportunity, I decided to write another book on Lisp. This would be a popular book, the sort of book that could be used as a textbook. I imagined myself living frugally off the royalties and spending all my time painting. (The painting on the cover of this book, ANSI Common Lisp, is one that I painted around this time.)\\n\\nThe best thing about New York for me was the presence of Idelle and Julian Weber. Idelle Weber was a painter, one of the early photorealists, and I\\'d taken her painting class at Harvard. I\\'ve never known a teacher more beloved by her students. Large numbers of former students kept in touch with her, including me. After I moved to New York I became her de facto studio assistant.\\n\\nShe liked to paint on big, square canvases, 4 to 5 feet on a side. One day in late 1994 as I was stretching one of these monsters there was something on the radio about a famous fund manager. He wasn\\'t that much older than me, and was super rich. The thought suddenly occurred to me: why don\\'t I become rich? Then I\\'ll be able to work on whatever I want.\\n\\nMeanwhile I\\'d been hearing more and more about this new thing called the World Wide Web. Robert Morris showed it to me when I visited him in Cambridge, where he was now in grad school at Harvard. It seemed to me that the web would be a big deal. I\\'d seen what graphical user interfaces had done for the popularity of microcomputers. It seemed like the web would do the same for the internet.\\n\\nIf I wanted to get rich, here was the next train leaving the station. I was right about that part. What I got wrong was the idea. I decided we should start a company to put art galleries online. I can\\'t honestly say, after reading so many Y Combinator applications, that this was the worst startup idea ever, but it was up there. Art galleries didn\\'t want to be online, and still don\\'t, not the fancy ones. That\\'s not how they sell. I wrote some software to generate web sites for galleries, and Robert wrote some to resize images and set up an http server to serve the pages. Then we tried to sign up galleries. To call this a difficult sale would be an understatement. It was difficult to give away. A few galleries let us make sites for them for free, but none paid us.'), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d', text='It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it\\'s an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\\n\\nI had to ban myself from writing essays during most of this time, or I\\'d never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you\\'re working on an interpreter written in itself, it\\'s hard to keep track of what\\'s happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it. So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools. It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished. Like McCarthy\\'s original Lisp, it\\'s a spec rather than an implementation, although like McCarthy\\'s Lisp it\\'s a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I\\'d had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who\\'d lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives. So I wrote a more detailed version for others to read, and this is the last sentence of it.\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nNotes\\n\\n[1] My experience skipped a step in the evolution of computers: time-sharing machines with interactive OSes. I went straight from batch processing to microcomputers, which made microcomputers seem all the more exciting.\\n\\n[2] Italian words for abstract concepts can nearly always be predicted from their English cognates (except for occasional traps like polluzione). It\\'s the everyday words that differ. So if you string together a lot of abstract concepts with a few simple verbs, you can make a little Italian go a long way.\\n\\n[3] I lived at Piazza San Felice 4, so my walk to the Accademia went straight down the spine of old Florence: past the Pitti, across the bridge, past Orsanmichele, between the Duomo and the Baptistery, and then up Via Ricasoli to Piazza San Marco. I saw Florence at street level in every possible condition, from empty dark winter evenings to sweltering summer days when the streets were packed with tourists.\\n\\n[4] You can of course paint people like still lives if you want to, and they\\'re willing. That sort of portrait is arguably the apex of still life painting, though the long sitting does tend to produce pained expressions in the sitters.\\n\\n[5] Interleaf was one of many companies that had smart people and built impressive technology, and yet got crushed by Moore\\'s Law. In the 1990s the exponential growth in the power of commodity (i.e.')]\n",
      "Stream Chat\n",
      "Stream Chat Response\n",
      "========\n",
      "Paul Graham spent his childhood growing up in Yorkville, a tiny corner of the Upper East Side of New York City, after his family moved from Britain to the United States. He lived in the same apartment from the 1990s, and worked hard to make a living. \n",
      "\n",
      "He also worked on a new Lisp called Bel, written in Arc, and learned painting. In 1993, he dropped out of RISD moved to New York City, where he lived with his family and worked as a studio assistant for Idelle Weber, a painter and early photorealist, whom he had taken a colour class with at Harvard. He worked on Bel intensively and says that it was hard but satisfying work. In 2019, Bel was finally finished and Graham wrote a bunch of essays about topics he had stacked up that he wanted to write about.Citations: [Citation(text='Yorkville', start=46, end=55, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='tiny corner of the Upper East Side of New York City', start=59, end=110, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='family moved from Britain to the United States.', start=122, end=169, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='lived in the same apartment from the 1990s', start=173, end=215, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='worked hard to make a living.', start=221, end=250, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='new Lisp called Bel, written in Arc', start=273, end=308, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d', '5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='learned painting.', start=314, end=331, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='1993', start=335, end=339, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='dropped out of RISD', start=344, end=363, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='New York City', start=373, end=386, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='lived with his family', start=397, end=418, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='worked as a studio assistant for Idelle Weber', start=423, end=468, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='painter and early photorealist', start=472, end=502, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='colour class with at Harvard.', start=524, end=553, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='hard but satisfying work.', start=604, end=629, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='2019', start=633, end=637, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='finished', start=655, end=663, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='wrote a bunch of essays about topics he had stacked up that he wanted to write about.', start=675, end=760, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d', text='It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it\\'s an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\\n\\nI had to ban myself from writing essays during most of this time, or I\\'d never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you\\'re working on an interpreter written in itself, it\\'s hard to keep track of what\\'s happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it. So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools. It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished. Like McCarthy\\'s original Lisp, it\\'s a spec rather than an implementation, although like McCarthy\\'s Lisp it\\'s a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I\\'d had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who\\'d lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives. So I wrote a more detailed version for others to read, and this is the last sentence of it.\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nNotes\\n\\n[1] My experience skipped a step in the evolution of computers: time-sharing machines with interactive OSes. I went straight from batch processing to microcomputers, which made microcomputers seem all the more exciting.\\n\\n[2] Italian words for abstract concepts can nearly always be predicted from their English cognates (except for occasional traps like polluzione). It\\'s the everyday words that differ. So if you string together a lot of abstract concepts with a few simple verbs, you can make a little Italian go a long way.\\n\\n[3] I lived at Piazza San Felice 4, so my walk to the Accademia went straight down the spine of old Florence: past the Pitti, across the bridge, past Orsanmichele, between the Duomo and the Baptistery, and then up Via Ricasoli to Piazza San Marco. I saw Florence at street level in every possible condition, from empty dark winter evenings to sweltering summer days when the streets were packed with tourists.\\n\\n[4] You can of course paint people like still lives if you want to, and they\\'re willing. That sort of portrait is arguably the apex of still life painting, though the long sitting does tend to produce pained expressions in the sitters.\\n\\n[5] Interleaf was one of many companies that had smart people and built impressive technology, and yet got crushed by Moore\\'s Law. In the 1990s the exponential growth in the power of commodity (i.e.'), Document(id='5ef32917-0965-4551-8359-e8b92557965b', text='For example, when you see a painting that looks like a certain kind of cartoon, you know it\\'s by Roy Lichtenstein. So if you see a big painting of this type hanging in the apartment of a hedge fund manager, you know he paid millions of dollars for it. That\\'s not always why artists have a signature style, but it\\'s usually why buyers pay a lot for such work. [6]\\n\\nThere were plenty of earnest students too: kids who \"could draw\" in high school, and now had come to what was supposed to be the best art school in the country, to learn to draw even better. They tended to be confused and demoralized by what they found at RISD, but they kept going, because painting was what they did. I was not one of the kids who could draw in high school, but at RISD I was definitely closer to their tribe than the tribe of signature style seekers.\\n\\nI learned a lot in the color class I took at RISD, but otherwise I was basically teaching myself to paint, and I could do that for free. So in 1993 I dropped out. I hung around Providence for a bit, and then my college friend Nancy Parmet did me a big favor. A rent-controlled apartment in a building her mother owned in New York was becoming vacant. Did I want it? It wasn\\'t much more than my current place, and New York was supposed to be where the artists were. So yes, I wanted it! [7]\\n\\nAsterix comics begin by zooming in on a tiny corner of Roman Gaul that turns out not to be controlled by the Romans. You can do something similar on a map of New York City: if you zoom in on the Upper East Side, there\\'s a tiny corner that\\'s not rich, or at least wasn\\'t in 1993. It\\'s called Yorkville, and that was my new home. Now I was a New York artist — in the strictly technical sense of making paintings and living in New York.\\n\\nI was nervous about money, because I could sense that Interleaf was on the way down. Freelance Lisp hacking work was very rare, and I didn\\'t want to have to program in another language, which in those days would have meant C++ if I was lucky. So with my unerring nose for financial opportunity, I decided to write another book on Lisp. This would be a popular book, the sort of book that could be used as a textbook. I imagined myself living frugally off the royalties and spending all my time painting. (The painting on the cover of this book, ANSI Common Lisp, is one that I painted around this time.)\\n\\nThe best thing about New York for me was the presence of Idelle and Julian Weber. Idelle Weber was a painter, one of the early photorealists, and I\\'d taken her painting class at Harvard. I\\'ve never known a teacher more beloved by her students. Large numbers of former students kept in touch with her, including me. After I moved to New York I became her de facto studio assistant.\\n\\nShe liked to paint on big, square canvases, 4 to 5 feet on a side. One day in late 1994 as I was stretching one of these monsters there was something on the radio about a famous fund manager. He wasn\\'t that much older than me, and was super rich. The thought suddenly occurred to me: why don\\'t I become rich? Then I\\'ll be able to work on whatever I want.\\n\\nMeanwhile I\\'d been hearing more and more about this new thing called the World Wide Web. Robert Morris showed it to me when I visited him in Cambridge, where he was now in grad school at Harvard. It seemed to me that the web would be a big deal. I\\'d seen what graphical user interfaces had done for the popularity of microcomputers. It seemed like the web would do the same for the internet.\\n\\nIf I wanted to get rich, here was the next train leaving the station. I was right about that part. What I got wrong was the idea. I decided we should start a company to put art galleries online. I can\\'t honestly say, after reading so many Y Combinator applications, that this was the worst startup idea ever, but it was up there. Art galleries didn\\'t want to be online, and still don\\'t, not the fancy ones. That\\'s not how they sell. I wrote some software to generate web sites for galleries, and Robert wrote some to resize images and set up an http server to serve the pages. Then we tried to sign up galleries. To call this a difficult sale would be an understatement. It was difficult to give away. A few galleries let us make sites for them for free, but none paid us.')]\n",
      "Async Stream Chat\n",
      "Async Stream Chat Response\n",
      "========\n",
      "Paul Graham spent his childhood growing up in Yorkville, a tiny corner of the Upper East Side of New York City. His family having moved to the United States from Britain, Paul lived in the same apartment from the 1990s. He worked hard to make a living and also worked on a new Lisp called Bel, written in Arc.\n",
      "\n",
      "Notably, Graham dropped out of RISD in 1993 and moved to New York City to live with his family and work as a studio assistant for Idelle Weber, a painter and early photorealist, whom he had taken a colour class with at Harvard. He worked on Bel intensively and says that it was hard but satisfying work. In 2019, Bel was finally finished and Graham wrote a bunch of essays about topics he had stacked up that he wanted to write about.Citations: [Citation(text='Yorkville, a tiny corner of the Upper East Side of New York City.', start=46, end=111, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='same apartment from the 1990s.', start=189, end=219, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='worked hard to make a living', start=223, end=251, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='new Lisp called Bel, written in Arc.', start=273, end=309, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='dropped out of RISD in 1993', start=327, end=354, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='work as a studio assistant for Idelle Weber, a painter and early photorealist', start=410, end=487, document_ids=['5ef32917-0965-4551-8359-e8b92557965b']), Citation(text='hard but satisfying work.', start=589, end=614, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='2019, Bel was finally finished', start=618, end=648, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d']), Citation(text='essays about topics he had stacked up that he wanted to write about.', start=677, end=745, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d', text='It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it\\'s an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\\n\\nI had to ban myself from writing essays during most of this time, or I\\'d never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you\\'re working on an interpreter written in itself, it\\'s hard to keep track of what\\'s happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it. So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools. It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished. Like McCarthy\\'s original Lisp, it\\'s a spec rather than an implementation, although like McCarthy\\'s Lisp it\\'s a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I\\'d had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who\\'d lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives. So I wrote a more detailed version for others to read, and this is the last sentence of it.\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nNotes\\n\\n[1] My experience skipped a step in the evolution of computers: time-sharing machines with interactive OSes. I went straight from batch processing to microcomputers, which made microcomputers seem all the more exciting.\\n\\n[2] Italian words for abstract concepts can nearly always be predicted from their English cognates (except for occasional traps like polluzione). It\\'s the everyday words that differ. So if you string together a lot of abstract concepts with a few simple verbs, you can make a little Italian go a long way.\\n\\n[3] I lived at Piazza San Felice 4, so my walk to the Accademia went straight down the spine of old Florence: past the Pitti, across the bridge, past Orsanmichele, between the Duomo and the Baptistery, and then up Via Ricasoli to Piazza San Marco. I saw Florence at street level in every possible condition, from empty dark winter evenings to sweltering summer days when the streets were packed with tourists.\\n\\n[4] You can of course paint people like still lives if you want to, and they\\'re willing. That sort of portrait is arguably the apex of still life painting, though the long sitting does tend to produce pained expressions in the sitters.\\n\\n[5] Interleaf was one of many companies that had smart people and built impressive technology, and yet got crushed by Moore\\'s Law. In the 1990s the exponential growth in the power of commodity (i.e.'), Document(id='5ef32917-0965-4551-8359-e8b92557965b', text='For example, when you see a painting that looks like a certain kind of cartoon, you know it\\'s by Roy Lichtenstein. So if you see a big painting of this type hanging in the apartment of a hedge fund manager, you know he paid millions of dollars for it. That\\'s not always why artists have a signature style, but it\\'s usually why buyers pay a lot for such work. [6]\\n\\nThere were plenty of earnest students too: kids who \"could draw\" in high school, and now had come to what was supposed to be the best art school in the country, to learn to draw even better. They tended to be confused and demoralized by what they found at RISD, but they kept going, because painting was what they did. I was not one of the kids who could draw in high school, but at RISD I was definitely closer to their tribe than the tribe of signature style seekers.\\n\\nI learned a lot in the color class I took at RISD, but otherwise I was basically teaching myself to paint, and I could do that for free. So in 1993 I dropped out. I hung around Providence for a bit, and then my college friend Nancy Parmet did me a big favor. A rent-controlled apartment in a building her mother owned in New York was becoming vacant. Did I want it? It wasn\\'t much more than my current place, and New York was supposed to be where the artists were. So yes, I wanted it! [7]\\n\\nAsterix comics begin by zooming in on a tiny corner of Roman Gaul that turns out not to be controlled by the Romans. You can do something similar on a map of New York City: if you zoom in on the Upper East Side, there\\'s a tiny corner that\\'s not rich, or at least wasn\\'t in 1993. It\\'s called Yorkville, and that was my new home. Now I was a New York artist — in the strictly technical sense of making paintings and living in New York.\\n\\nI was nervous about money, because I could sense that Interleaf was on the way down. Freelance Lisp hacking work was very rare, and I didn\\'t want to have to program in another language, which in those days would have meant C++ if I was lucky. So with my unerring nose for financial opportunity, I decided to write another book on Lisp. This would be a popular book, the sort of book that could be used as a textbook. I imagined myself living frugally off the royalties and spending all my time painting. (The painting on the cover of this book, ANSI Common Lisp, is one that I painted around this time.)\\n\\nThe best thing about New York for me was the presence of Idelle and Julian Weber. Idelle Weber was a painter, one of the early photorealists, and I\\'d taken her painting class at Harvard. I\\'ve never known a teacher more beloved by her students. Large numbers of former students kept in touch with her, including me. After I moved to New York I became her de facto studio assistant.\\n\\nShe liked to paint on big, square canvases, 4 to 5 feet on a side. One day in late 1994 as I was stretching one of these monsters there was something on the radio about a famous fund manager. He wasn\\'t that much older than me, and was super rich. The thought suddenly occurred to me: why don\\'t I become rich? Then I\\'ll be able to work on whatever I want.\\n\\nMeanwhile I\\'d been hearing more and more about this new thing called the World Wide Web. Robert Morris showed it to me when I visited him in Cambridge, where he was now in grad school at Harvard. It seemed to me that the web would be a big deal. I\\'d seen what graphical user interfaces had done for the popularity of microcomputers. It seemed like the web would do the same for the internet.\\n\\nIf I wanted to get rich, here was the next train leaving the station. I was right about that part. What I got wrong was the idea. I decided we should start a company to put art galleries online. I can\\'t honestly say, after reading so many Y Combinator applications, that this was the worst startup idea ever, but it was up there. Art galleries didn\\'t want to be online, and still don\\'t, not the fancy ones. That\\'s not how they sell. I wrote some software to generate web sites for galleries, and Robert wrote some to resize images and set up an http server to serve the pages. Then we tried to sign up galleries. To call this a difficult sale would be an understatement. It was difficult to give away. A few galleries let us make sites for them for free, but none paid us.')]\n",
      "\n",
      "Query \n",
      "=====\n",
      "When and how did Paul Graham's mother die?\n",
      "Chat\n",
      "Chat Response\n",
      "========\n",
      "Paul Graham's mother died on January 15, 2014, due to a blood clot caused by colon cancer leading to a stroke.\n",
      "Citations: [Citation(text='January 15, 2014', start=29, end=45, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239']), Citation(text='blood clot caused by colon cancer', start=56, end=89, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239']), Citation(text='stroke.', start=103, end=110, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239'])]\n",
      "Documents: [Document(id='27575ca6-237f-4744-8eac-9162cc53d239', text='There were parts of the job I didn\\'t like. Disputes between cofounders, figuring out when people were lying to us, fighting with people who maltreated the startups, and so on. But I worked hard even at the parts I didn\\'t like. I was haunted by something Kevin Hale once said about companies: \"No one works harder than the boss.\" He meant it both descriptively and prescriptively, and it was the second part that scared me. I wanted YC to be good, so if how hard I worked set the upper bound on how hard everyone else worked, I\\'d better work very hard.\\n\\nOne day in 2010, when he was visiting California for interviews, Robert Morris did something astonishing: he offered me unsolicited advice. I can only remember him doing that once before. One day at Viaweb, when I was bent over double from a kidney stone, he suggested that it would be a good idea for him to take me to the hospital. That was what it took for Rtm to offer unsolicited advice. So I remember his exact words very clearly. \"You know,\" he said, \"you should make sure Y Combinator isn\\'t the last cool thing you do.\"\\n\\nAt the time I didn\\'t understand what he meant, but gradually it dawned on me that he was saying I should quit. This seemed strange advice, because YC was doing great. But if there was one thing rarer than Rtm offering advice, it was Rtm being wrong. So this set me thinking. It was true that on my current trajectory, YC would be the last thing I did, because it was only taking up more of my attention. It had already eaten Arc, and was in the process of eating essays too. Either YC was my life\\'s work or I\\'d have to leave eventually. And it wasn\\'t, so I would.\\n\\nIn the summer of 2012 my mother had a stroke, and the cause turned out to be a blood clot caused by colon cancer. The stroke destroyed her balance, and she was put in a nursing home, but she really wanted to get out of it and back to her house, and my sister and I were determined to help her do it. I used to fly up to Oregon to visit her regularly, and I had a lot of time to think on those flights. On one of them I realized I was ready to hand YC over to someone else.\\n\\nI asked Jessica if she wanted to be president, but she didn\\'t, so we decided we\\'d try to recruit Sam Altman. We talked to Robert and Trevor and we agreed to make it a complete changing of the guard. Up till that point YC had been controlled by the original LLC we four had started. But we wanted YC to last for a long time, and to do that it couldn\\'t be controlled by the founders. So if Sam said yes, we\\'d let him reorganize YC. Robert and I would retire, and Jessica and Trevor would become ordinary partners.\\n\\nWhen we asked Sam if he wanted to be president of YC, initially he said no. He wanted to start a startup to make nuclear reactors. But I kept at it, and in October 2013 he finally agreed. We decided he\\'d take over starting with the winter 2014 batch. For the rest of 2013 I left running YC more and more to Sam, partly so he could learn the job, and partly because I was focused on my mother, whose cancer had returned.\\n\\nShe died on January 15, 2014. We knew this was coming, but it was still hard when it did.\\n\\nI kept working on YC till March, to help get that batch of startups through Demo Day, then I checked out pretty completely. (I still talk to alumni and to new startups working on things I\\'m interested in, but that only takes a few hours a week.)\\n\\nWhat should I do next? Rtm\\'s advice hadn\\'t included anything about that. I wanted to do something completely different, so I decided I\\'d paint. I wanted to see how good I could get if I really focused on it. So the day after I stopped working on YC, I started painting. I was rusty and it took a while to get back into shape, but it was at least completely engaging. [18]\\n\\nI spent most of the rest of 2014 painting. I\\'d never been able to work so uninterruptedly before, and I got to be better than I had been. Not good enough, but better. Then in November, right in the middle of a painting, I ran out of steam.')]\n",
      "Async Chat\n",
      "Async Chat Response\n",
      "========\n",
      "Paul Graham's mother died of a stroke on January 15, 2014. The stroke was caused by a blood clot created by colon cancer.\n",
      "Citations: [Citation(text='stroke', start=31, end=37, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239']), Citation(text='January 15, 2014.', start=41, end=58, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239']), Citation(text='blood clot', start=86, end=96, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239']), Citation(text='colon cancer.', start=108, end=121, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239'])]\n",
      "Documents: [Document(id='27575ca6-237f-4744-8eac-9162cc53d239', text='There were parts of the job I didn\\'t like. Disputes between cofounders, figuring out when people were lying to us, fighting with people who maltreated the startups, and so on. But I worked hard even at the parts I didn\\'t like. I was haunted by something Kevin Hale once said about companies: \"No one works harder than the boss.\" He meant it both descriptively and prescriptively, and it was the second part that scared me. I wanted YC to be good, so if how hard I worked set the upper bound on how hard everyone else worked, I\\'d better work very hard.\\n\\nOne day in 2010, when he was visiting California for interviews, Robert Morris did something astonishing: he offered me unsolicited advice. I can only remember him doing that once before. One day at Viaweb, when I was bent over double from a kidney stone, he suggested that it would be a good idea for him to take me to the hospital. That was what it took for Rtm to offer unsolicited advice. So I remember his exact words very clearly. \"You know,\" he said, \"you should make sure Y Combinator isn\\'t the last cool thing you do.\"\\n\\nAt the time I didn\\'t understand what he meant, but gradually it dawned on me that he was saying I should quit. This seemed strange advice, because YC was doing great. But if there was one thing rarer than Rtm offering advice, it was Rtm being wrong. So this set me thinking. It was true that on my current trajectory, YC would be the last thing I did, because it was only taking up more of my attention. It had already eaten Arc, and was in the process of eating essays too. Either YC was my life\\'s work or I\\'d have to leave eventually. And it wasn\\'t, so I would.\\n\\nIn the summer of 2012 my mother had a stroke, and the cause turned out to be a blood clot caused by colon cancer. The stroke destroyed her balance, and she was put in a nursing home, but she really wanted to get out of it and back to her house, and my sister and I were determined to help her do it. I used to fly up to Oregon to visit her regularly, and I had a lot of time to think on those flights. On one of them I realized I was ready to hand YC over to someone else.\\n\\nI asked Jessica if she wanted to be president, but she didn\\'t, so we decided we\\'d try to recruit Sam Altman. We talked to Robert and Trevor and we agreed to make it a complete changing of the guard. Up till that point YC had been controlled by the original LLC we four had started. But we wanted YC to last for a long time, and to do that it couldn\\'t be controlled by the founders. So if Sam said yes, we\\'d let him reorganize YC. Robert and I would retire, and Jessica and Trevor would become ordinary partners.\\n\\nWhen we asked Sam if he wanted to be president of YC, initially he said no. He wanted to start a startup to make nuclear reactors. But I kept at it, and in October 2013 he finally agreed. We decided he\\'d take over starting with the winter 2014 batch. For the rest of 2013 I left running YC more and more to Sam, partly so he could learn the job, and partly because I was focused on my mother, whose cancer had returned.\\n\\nShe died on January 15, 2014. We knew this was coming, but it was still hard when it did.\\n\\nI kept working on YC till March, to help get that batch of startups through Demo Day, then I checked out pretty completely. (I still talk to alumni and to new startups working on things I\\'m interested in, but that only takes a few hours a week.)\\n\\nWhat should I do next? Rtm\\'s advice hadn\\'t included anything about that. I wanted to do something completely different, so I decided I\\'d paint. I wanted to see how good I could get if I really focused on it. So the day after I stopped working on YC, I started painting. I was rusty and it took a while to get back into shape, but it was at least completely engaging. [18]\\n\\nI spent most of the rest of 2014 painting. I\\'d never been able to work so uninterruptedly before, and I got to be better than I had been. Not good enough, but better. Then in November, right in the middle of a painting, I ran out of steam.')]\n",
      "Stream Chat\n",
      "Stream Chat Response\n",
      "========\n",
      "Paul Graham's mother died on January 15, 2014, due to a stroke caused by a blood clot created by colon cancer. She had a stroke in 2012 and her balance was destroyed afterwards, leading her to be put in a nursing home against her will.Citations: [Citation(text='January 15, 2014', start=29, end=45, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:5']), Citation(text='stroke', start=56, end=62, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2', '27575ca6-237f-4744-8eac-9162cc53d239:3']), Citation(text='blood clot created by colon cancer.', start=75, end=110, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2']), Citation(text='stroke in 2012', start=121, end=135, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2']), Citation(text='balance was destroyed afterwards', start=144, end=176, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:3']), Citation(text='put in a nursing home against her will.', start=196, end=235, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:3'])]\n",
      "Documents: [Document(id='27575ca6-237f-4744-8eac-9162cc53d239:2', text=\" This seemed strange advice, because YC was doing great. But if there was one thing rarer than Rtm offering advice, it was Rtm being wrong. So this set me thinking. It was true that on my current trajectory, YC would be the last thing I did, because it was only taking up more of my attention. It had already eaten Arc, and was in the process of eating essays too. Either YC was my life's work or I'd have to leave eventually. And it wasn't, so I would.\\n\\nIn the summer of 2012 my mother had a stroke, and the cause turned out to be a blood clot caused by colon cancer.\"), Document(id='27575ca6-237f-4744-8eac-9162cc53d239:5', text=\" For the rest of 2013 I left running YC more and more to Sam, partly so he could learn the job, and partly because I was focused on my mother, whose cancer had returned.\\n\\nShe died on January 15, 2014. We knew this was coming, but it was still hard when it did.\\n\\nI kept working on YC till March, to help get that batch of startups through Demo Day, then I checked out pretty completely. (I still talk to alumni and to new startups working on things I'm interested in, but that only takes a few hours a week.)\\n\\nWhat should I do next?\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='27575ca6-237f-4744-8eac-9162cc53d239:3', text=\" The stroke destroyed her balance, and she was put in a nursing home, but she really wanted to get out of it and back to her house, and my sister and I were determined to help her do it. I used to fly up to Oregon to visit her regularly, and I had a lot of time to think on those flights. On one of them I realized I was ready to hand YC over to someone else.\\n\\nI asked Jessica if she wanted to be president, but she didn't, so we decided we'd try to recruit Sam Altman. We talked to Robert and Trevor and we agreed to make it a complete changing of the guard.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\")]\n",
      "Async Stream Chat\n",
      "Async Stream Chat Response\n",
      "========\n",
      "Paul Graham's mother died on January 15, 2014, due to a stroke caused by a blood clot created by colon cancer. She had a stroke in 2012 and the stroke destroyed her balance, leading her to be put in a nursing home against her will.Citations: [Citation(text='January 15, 2014', start=29, end=45, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:5']), Citation(text='stroke', start=56, end=62, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2', '27575ca6-237f-4744-8eac-9162cc53d239:3']), Citation(text='blood clot created by colon cancer.', start=75, end=110, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2']), Citation(text='stroke in 2012', start=121, end=135, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:2']), Citation(text='destroyed her balance', start=151, end=172, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:3']), Citation(text='put in a nursing home against her will.', start=192, end=231, document_ids=['27575ca6-237f-4744-8eac-9162cc53d239:3'])]\n",
      "Documents: [Document(id='27575ca6-237f-4744-8eac-9162cc53d239:2', text=\" This seemed strange advice, because YC was doing great. But if there was one thing rarer than Rtm offering advice, it was Rtm being wrong. So this set me thinking. It was true that on my current trajectory, YC would be the last thing I did, because it was only taking up more of my attention. It had already eaten Arc, and was in the process of eating essays too. Either YC was my life's work or I'd have to leave eventually. And it wasn't, so I would.\\n\\nIn the summer of 2012 my mother had a stroke, and the cause turned out to be a blood clot caused by colon cancer.\"), Document(id='27575ca6-237f-4744-8eac-9162cc53d239:5', text=\" For the rest of 2013 I left running YC more and more to Sam, partly so he could learn the job, and partly because I was focused on my mother, whose cancer had returned.\\n\\nShe died on January 15, 2014. We knew this was coming, but it was still hard when it did.\\n\\nI kept working on YC till March, to help get that batch of startups through Demo Day, then I checked out pretty completely. (I still talk to alumni and to new startups working on things I'm interested in, but that only takes a few hours a week.)\\n\\nWhat should I do next?\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='27575ca6-237f-4744-8eac-9162cc53d239:3', text=\" The stroke destroyed her balance, and she was put in a nursing home, but she really wanted to get out of it and back to her house, and my sister and I were determined to help her do it. I used to fly up to Oregon to visit her regularly, and I had a lot of time to think on those flights. On one of them I realized I was ready to hand YC over to someone else.\\n\\nI asked Jessica if she wanted to be president, but she didn't, so we decided we'd try to recruit Sam Altman. We talked to Robert and Trevor and we agreed to make it a complete changing of the guard.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\")]\n",
      "\n",
      "Query \n",
      "=====\n",
      "What, in Paul Graham's opinion, is the most distinctive thing about YC?\n",
      "Chat\n",
      "Chat Response\n",
      "========\n",
      "In Paul Graham's opinion, the most distinctive thing about Y Combinator is the willingness to work on projects that are not considered prestigious. He notes that this is not necessarily good in itself but indicates a higher chance of discovering something real and genuine in the work produced. He cites his own experience, dropping out of RISD to work on a Lisp language called Bel, as an example of this.\n",
      "Citations: [Citation(text='projects that are not considered prestigious.', start=102, end=147, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4', 'a6256753-33e3-4335-bfd7-beecf19af6c4:5']), Citation(text='not necessarily good in itself', start=170, end=200, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4', 'a6256753-33e3-4335-bfd7-beecf19af6c4:5']), Citation(text='higher chance of discovering something real and genuine in the work produced.', start=217, end=294, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='dropping out of RISD', start=324, end=344, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='Lisp language called Bel', start=358, end=382, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4'])]\n",
      "Documents: [Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:4', text=\" Viaweb and Y Combinator both seemed lame when we started them. I still get the glassy eye from strangers when they ask what I'm writing, and I explain that it's an essay I'm going to publish on my web site. Even Lisp, though prestigious intellectually in something like the way Latin is, also seems about as hip.\\n\\nIt's not that unprestigious types of work are good per se. But when you find yourself drawn to some kind of work despite its current lack of prestige, it's a sign both that there's something real to be discovered there, and that you have the right kind of motives.\"), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:5', text=\" Impure motives are a big danger for the ambitious. If anything is going to lead you astray, it will be the desire to impress people. So while working on things that aren't prestigious doesn't guarantee you're on the right track, it at least guarantees you're not on the most common type of wrong one.\\n\\nOver the next several years I wrote lots of essays about all kinds of different topics. O'Reilly reprinted a collection of them as a book, called Hackers & Painters after one of the essays in it. I also worked on spam filters, and did some more painting. I used to have dinners for a group of friends every thursday night, which taught me how to cook for groups.\")]\n",
      "Async Chat\n",
      "Async Chat Response\n",
      "========\n",
      "Paul Graham believes that the biggest distinctive thing about YC is its willingness to work on projects that are not considered prestigious. He argues that this shows a genuine motive to discover something real and authentic in a field. He cites his own experience, dropping out of RISD to work on a Lisp language called Bel, as an example of this.\n",
      "Citations: [Citation(text='willingness to work on projects that are not considered prestigious.', start=72, end=140, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='genuine motive to discover something real and authentic', start=169, end=224, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='cites his own experience', start=240, end=264, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='dropping out of RISD', start=266, end=286, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='Lisp language called Bel', start=300, end=324, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4'])]\n",
      "Documents: [Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:4', text=\" Viaweb and Y Combinator both seemed lame when we started them. I still get the glassy eye from strangers when they ask what I'm writing, and I explain that it's an essay I'm going to publish on my web site. Even Lisp, though prestigious intellectually in something like the way Latin is, also seems about as hip.\\n\\nIt's not that unprestigious types of work are good per se. But when you find yourself drawn to some kind of work despite its current lack of prestige, it's a sign both that there's something real to be discovered there, and that you have the right kind of motives.\")]\n",
      "Stream Chat\n",
      "Stream Chat Response\n",
      "========\n",
      "Paul Graham believes that the biggest distinctive thing about YC is its willingness to work on projects that are not considered prestigious. He argues that this shows a genuine motive to discover something real and authentic in a field. He cites his own experience, dropping out of RISD to work on a Lisp language called Bel, as an example of this.Citations: [Citation(text='projects that are not considered prestigious.', start=95, end=140, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4', 'a6256753-33e3-4335-bfd7-beecf19af6c4:5']), Citation(text='genuine motive to discover something real and authentic', start=169, end=224, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='dropping out of RISD to work on a Lisp language called Bel', start=266, end=324, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4'])]\n",
      "Documents: [Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:0', text=\"I was invited to give a talk at a Lisp conference, so I gave one about how we'd used Lisp at Viaweb. Afterward I put a postscript file of this talk online, on paulgraham.com, which I'd created years before using Viaweb but had never used for anything. In one day it got 30,000 page views. What on earth had happened? The referring urls showed that someone had posted it on Slashdot. [10]\\n\\nWow, I thought, there's an audience. If I write something and put it on the web, anyone can read it. That may seem obvious now, but it was surprising then.\"), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:4', text=\" Viaweb and Y Combinator both seemed lame when we started them. I still get the glassy eye from strangers when they ask what I'm writing, and I explain that it's an essay I'm going to publish on my web site. Even Lisp, though prestigious intellectually in something like the way Latin is, also seems about as hip.\\n\\nIt's not that unprestigious types of work are good per se. But when you find yourself drawn to some kind of work despite its current lack of prestige, it's a sign both that there's something real to be discovered there, and that you have the right kind of motives.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:5', text=\" Impure motives are a big danger for the ambitious. If anything is going to lead you astray, it will be the desire to impress people. So while working on things that aren't prestigious doesn't guarantee you're on the right track, it at least guarantees you're not on the most common type of wrong one.\\n\\nOver the next several years I wrote lots of essays about all kinds of different topics. O'Reilly reprinted a collection of them as a book, called Hackers & Painters after one of the essays in it. I also worked on spam filters, and did some more painting. I used to have dinners for a group of friends every thursday night, which taught me how to cook for groups.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\")]\n",
      "Async Stream Chat\n",
      "Async Stream Chat Response\n",
      "========\n",
      "Paul Graham believes that the biggest distinctive thing about YC is its willingness to work on projects that are not considered prestigious. He argues that this shows a genuine motive to discover something real and authentic in a field. He cites his own experience, dropping out of RISD to work on a Lisp language called Bel, as an example of this.Citations: [Citation(text='projects that are not considered prestigious.', start=95, end=140, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4', 'a6256753-33e3-4335-bfd7-beecf19af6c4:5']), Citation(text='genuine motive to discover something real and authentic in a field.', start=169, end=236, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4']), Citation(text='dropping out of RISD to work on a Lisp language called Bel', start=266, end=324, document_ids=['a6256753-33e3-4335-bfd7-beecf19af6c4:4'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:0', text=\"I was invited to give a talk at a Lisp conference, so I gave one about how we'd used Lisp at Viaweb. Afterward I put a postscript file of this talk online, on paulgraham.com, which I'd created years before using Viaweb but had never used for anything. In one day it got 30,000 page views. What on earth had happened? The referring urls showed that someone had posted it on Slashdot. [10]\\n\\nWow, I thought, there's an audience. If I write something and put it on the web, anyone can read it. That may seem obvious now, but it was surprising then.\"), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:4', text=\" Viaweb and Y Combinator both seemed lame when we started them. I still get the glassy eye from strangers when they ask what I'm writing, and I explain that it's an essay I'm going to publish on my web site. Even Lisp, though prestigious intellectually in something like the way Latin is, also seems about as hip.\\n\\nIt's not that unprestigious types of work are good per se. But when you find yourself drawn to some kind of work despite its current lack of prestige, it's a sign both that there's something real to be discovered there, and that you have the right kind of motives.\"), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:1', text=' In the print era there was a narrow channel to readers, guarded by fierce monsters known as editors. The only way to get an audience for anything you wrote was to get it published as a book, or in a newspaper or magazine. Now anyone could publish anything.\\n\\nThis had been possible in principle since 1993, but not many people had realized it yet. I had been intimately involved with building the infrastructure of the web for most of that time, and a writer as well, and it had taken me 8 years to realize it. Even then it took me several years to understand the implications.'), Document(id='a6256753-33e3-4335-bfd7-beecf19af6c4:5', text=\" Impure motives are a big danger for the ambitious. If anything is going to lead you astray, it will be the desire to impress people. So while working on things that aren't prestigious doesn't guarantee you're on the right track, it at least guarantees you're not on the most common type of wrong one.\\n\\nOver the next several years I wrote lots of essays about all kinds of different topics. O'Reilly reprinted a collection of them as a book, called Hackers & Painters after one of the essays in it. I also worked on spam filters, and did some more painting. I used to have dinners for a group of friends every thursday night, which taught me how to cook for groups.\")]\n",
      "\n",
      "Query \n",
      "=====\n",
      "When and how did Paul Graham meet Jessica Livingston?\n",
      "Chat\n",
      "Chat Response\n",
      "========\n",
      "Paul Graham met Jessica Livingston at a party in October 2003. She was a guest of one of Paul's friends and Paul says he immediately liked her a lot. At the time, Jessica was working for a Boston investment bank, in charge of marketing. After being fired from her position there, she interviewed for a marketing position for a Boston VC firm in 2005, where Paul was interviewing her and discussing the ways to improve the VC firm. Eventually, Paul and Jessica became co-founders of Y Combinator along with Robert and Trevor.\n",
      "Citations: [Citation(text='party in October 2003.', start=40, end=62, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text=\"guest of one of Paul's friends\", start=73, end=103, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text='immediately liked her a lot.', start=121, end=149, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text='Boston investment bank, in charge of marketing.', start=189, end=236, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:1']), Citation(text='fired from her position there', start=249, end=278, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:1']), Citation(text='interviewed for a marketing position for a Boston VC firm in 2005', start=284, end=349, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:1']), Citation(text='discussing the ways to improve the VC firm.', start=387, end=430, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:1']), Citation(text='co-founders of Y Combinator along with Robert and Trevor.', start=467, end=524, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:4'])]\n",
      "Documents: [Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:0', text=\"And I bought another building in Cambridge, a former candy factory (and later, twas said, porn studio), to use as an office.\\n\\nOne night in October 2003 there was a big party at my house. It was a clever idea of my friend Maria Daniels, who was one of the thursday diners. Three separate hosts would all invite their friends to one party. So for every guest, two thirds of the other guests would be people they didn't know but would probably like. One of the guests was someone I didn't know but would turn out to like a lot: a woman called Jessica Livingston.\"), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:1', text=' A couple days later I asked her out.\\n\\nJessica was in charge of marketing at a Boston investment bank. This bank thought it understood startups, but over the next year, as she met friends of mine from the startup world, she was surprised how different reality was. And how colorful their stories were. So she decided to compile a book of interviews with startup founders.\\n\\nWhen the bank had financial problems and she had to fire half her staff, she started looking for a new job. In early 2005 she interviewed for a marketing job at a Boston VC firm. It took them weeks to make up their minds, and during this time I started telling her about all the things that needed to be fixed about venture capital.'), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:4', text=\"\\n\\nMeanwhile I had been scheming with Robert and Trevor about projects we could work on together. I missed working with them, and it seemed like there had to be something we could collaborate on.\\n\\nAs Jessica and I were walking home from dinner on March 11, at the corner of Garden and Walker streets, these three threads converged. Screw the VCs who were taking so long to make up their minds. We'd start our own investment firm and actually implement the ideas we'd been talking about. I'd fund it, and Jessica could quit her job and work for it, and we'd get Robert and Trevor as partners too.\")]\n",
      "Async Chat\n",
      "Async Chat Response\n",
      "========\n",
      "Paul Graham met Jessica Livingston at a party in October 2003. She was a guest of one of Paul's friends and Paul says he immediately liked her a lot.\n",
      "Citations: [Citation(text='party in October 2003.', start=40, end=62, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text=\"guest of one of Paul's friends\", start=73, end=103, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text='immediately liked her a lot.', start=121, end=149, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0'])]\n",
      "Documents: [Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:0', text=\"And I bought another building in Cambridge, a former candy factory (and later, twas said, porn studio), to use as an office.\\n\\nOne night in October 2003 there was a big party at my house. It was a clever idea of my friend Maria Daniels, who was one of the thursday diners. Three separate hosts would all invite their friends to one party. So for every guest, two thirds of the other guests would be people they didn't know but would probably like. One of the guests was someone I didn't know but would turn out to like a lot: a woman called Jessica Livingston.\")]\n",
      "Stream Chat\n",
      "Stream Chat Response\n",
      "========\n",
      "Paul Graham met Jessica Livingston at a party in October 2003. She was a guest of one of Paul's friends and Paul says he immediately liked her a lot.Citations: [Citation(text='party in October 2003.', start=40, end=62, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text=\"guest of one of Paul's friends\", start=73, end=103, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text='immediately liked her a lot.', start=121, end=149, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0'])]\n",
      "Documents: [Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:1', text=' A couple days later I asked her out.\\n\\nJessica was in charge of marketing at a Boston investment bank. This bank thought it understood startups, but over the next year, as she met friends of mine from the startup world, she was surprised how different reality was. And how colorful their stories were. So she decided to compile a book of interviews with startup founders.\\n\\nWhen the bank had financial problems and she had to fire half her staff, she started looking for a new job. In early 2005 she interviewed for a marketing job at a Boston VC firm. It took them weeks to make up their minds, and during this time I started telling her about all the things that needed to be fixed about venture capital.'), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:0', text=\"And I bought another building in Cambridge, a former candy factory (and later, twas said, porn studio), to use as an office.\\n\\nOne night in October 2003 there was a big party at my house. It was a clever idea of my friend Maria Daniels, who was one of the thursday diners. Three separate hosts would all invite their friends to one party. So for every guest, two thirds of the other guests would be people they didn't know but would probably like. One of the guests was someone I didn't know but would turn out to like a lot: a woman called Jessica Livingston.\"), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:4', text=\"\\n\\nMeanwhile I had been scheming with Robert and Trevor about projects we could work on together. I missed working with them, and it seemed like there had to be something we could collaborate on.\\n\\nAs Jessica and I were walking home from dinner on March 11, at the corner of Garden and Walker streets, these three threads converged. Screw the VCs who were taking so long to make up their minds. We'd start our own investment firm and actually implement the ideas we'd been talking about. I'd fund it, and Jessica could quit her job and work for it, and we'd get Robert and Trevor as partners too.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:5', text=\" [13]\\n\\nOnce again, ignorance worked in our favor. We had no idea how to be angel investors, and in Boston in 2005 there were no Ron Conways to learn from. So we just made what seemed like the obvious choices, and some of the things we did turned out to be novel.\\n\\nThere are multiple components to Y Combinator, and we didn't figure them all out at once. The part we got first was to be an angel firm. In those days, those two words didn't go together. There were VC firms, which were organized companies with people whose job it was to make investments, but they only did big, million dollar investments.\")]\n",
      "Async Stream Chat\n",
      "Async Stream Chat Response\n",
      "========\n",
      "Paul Graham met Jessica Livingston at a party in October 2003. She was a guest of one of Paul's friends, and he says that he immediately liked her a lot.Citations: [Citation(text='party in October 2003.', start=40, end=62, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text=\"guest of one of Paul's friends\", start=73, end=103, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0']), Citation(text='immediately liked her a lot.', start=125, end=153, document_ids=['515aecbf-def6-45a8-a320-ff4127834e9b:0'])]\n",
      "Documents: [Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:1', text=' A couple days later I asked her out.\\n\\nJessica was in charge of marketing at a Boston investment bank. This bank thought it understood startups, but over the next year, as she met friends of mine from the startup world, she was surprised how different reality was. And how colorful their stories were. So she decided to compile a book of interviews with startup founders.\\n\\nWhen the bank had financial problems and she had to fire half her staff, she started looking for a new job. In early 2005 she interviewed for a marketing job at a Boston VC firm. It took them weeks to make up their minds, and during this time I started telling her about all the things that needed to be fixed about venture capital.'), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:0', text=\"And I bought another building in Cambridge, a former candy factory (and later, twas said, porn studio), to use as an office.\\n\\nOne night in October 2003 there was a big party at my house. It was a clever idea of my friend Maria Daniels, who was one of the thursday diners. Three separate hosts would all invite their friends to one party. So for every guest, two thirds of the other guests would be people they didn't know but would probably like. One of the guests was someone I didn't know but would turn out to like a lot: a woman called Jessica Livingston.\"), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:4', text=\"\\n\\nMeanwhile I had been scheming with Robert and Trevor about projects we could work on together. I missed working with them, and it seemed like there had to be something we could collaborate on.\\n\\nAs Jessica and I were walking home from dinner on March 11, at the corner of Garden and Walker streets, these three threads converged. Screw the VCs who were taking so long to make up their minds. We'd start our own investment firm and actually implement the ideas we'd been talking about. I'd fund it, and Jessica could quit her job and work for it, and we'd get Robert and Trevor as partners too.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='515aecbf-def6-45a8-a320-ff4127834e9b:5', text=\" [13]\\n\\nOnce again, ignorance worked in our favor. We had no idea how to be angel investors, and in Boston in 2005 there were no Ron Conways to learn from. So we just made what seemed like the obvious choices, and some of the things we did turned out to be novel.\\n\\nThere are multiple components to Y Combinator, and we didn't figure them all out at once. The part we got first was to be an angel firm. In those days, those two words didn't go together. There were VC firms, which were organized companies with people whose job it was to make investments, but they only did big, million dollar investments.\")]\n",
      "\n",
      "Query \n",
      "=====\n",
      "What is Bel, and when and where was it written?\n",
      "Chat\n",
      "Chat Response\n",
      "========\n",
      "Bel is a new Lisp written in Arc. Initially, the goal was to create an interpreter written in itself that could run fast enough to test. Paul Graham worked on Bel intensively and the project took four years to be completed, from March 26, 2015 to October 12, 2019. Most of the work on Bel was done in England.\n",
      "Citations: [Citation(text='new Lisp written in Arc.', start=9, end=33, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='interpreter written in itself', start=71, end=100, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0', 'def37b99-8ff3-49d4-94d4-fc235e40454d:1']), Citation(text='run fast enough to test.', start=112, end=136, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='four years', start=196, end=206, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='March 26, 2015', start=229, end=243, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='October 12, 2019.', start=247, end=264, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='England.', start=301, end=309, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:3'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:1', text=\"\\n\\nI had to ban myself from writing essays during most of this time, or I'd never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you're working on an interpreter written in itself, it's hard to keep track of what's happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:3', text=' It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished.')]\n",
      "Async Chat\n",
      "Async Chat Response\n",
      "========\n",
      "Bel is a new Lisp written in Arc. Initially, the goal was to create an interpreter written in itself that could run fast enough to test. Paul Graham worked on Bel intensively and the project took four years to be completed, from March 26, 2015, to October 12, 2019. Most of the work on Bel was done in England.\n",
      "Citations: [Citation(text='new Lisp written in Arc.', start=9, end=33, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='interpreter written in itself that could run fast enough to test.', start=71, end=136, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0', 'def37b99-8ff3-49d4-94d4-fc235e40454d:1']), Citation(text='worked on Bel intensively', start=149, end=174, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:2']), Citation(text='four years to be completed', start=196, end=222, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='March 26, 2015, to October 12, 2019.', start=229, end=265, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='England.', start=302, end=310, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:3'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:1', text=\"\\n\\nI had to ban myself from writing essays during most of this time, or I'd never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you're working on an interpreter written in itself, it's hard to keep track of what's happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:3', text=' It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished.')]\n",
      "Stream Chat\n",
      "Stream Chat Response\n",
      "========\n",
      "Bel is a new Lisp written in Arc. Initially, the goal was to create an interpreter written in itself that could run fast enough to test. Paul Graham worked on Bel intensively and the project took four years to be completed, from March 26, 2015, to October 12, 2019. Most of the work on Bel was done in England.Citations: [Citation(text='new Lisp written in Arc.', start=9, end=33, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='interpreter written in itself that could run fast enough to test.', start=71, end=136, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='worked on Bel intensively', start=149, end=174, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0', 'def37b99-8ff3-49d4-94d4-fc235e40454d:2']), Citation(text='four years to be completed', start=196, end=222, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='March 26, 2015, to October 12, 2019.', start=229, end=265, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='England.', start=302, end=310, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:3'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:1', text=\"\\n\\nI had to ban myself from writing essays during most of this time, or I'd never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you're working on an interpreter written in itself, it's hard to keep track of what's happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:4', text=\" Like McCarthy's original Lisp, it's a spec rather than an implementation, although like McCarthy's Lisp it's a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I'd had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who'd lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:3', text=' It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished.')]\n",
      "Async Stream Chat\n",
      "Async Stream Chat Response\n",
      "========\n",
      "Bel is a new Lisp written in Arc. Initially, the goal was to create an interpreter written in itself that could run fast enough to test. Paul Graham worked on Bel intensively and the project took four years to be completed, from March 26, 2015, to October 12, 2019. Most of the work on Bel was done in England.Citations: [Citation(text='new Lisp written in Arc.', start=9, end=33, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='interpreter written in itself that could run fast enough to test.', start=71, end=136, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='worked on Bel intensively', start=149, end=174, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0', 'def37b99-8ff3-49d4-94d4-fc235e40454d:2']), Citation(text='four years to be completed', start=196, end=222, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='March 26, 2015, to October 12, 2019.', start=229, end=265, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:0']), Citation(text='England.', start=302, end=310, document_ids=['def37b99-8ff3-49d4-94d4-fc235e40454d:3'])]\n",
      "Documents: [Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:0', text=\"It took 4 years, from March 26, 2015 to October 12, 2019. It was fortunate that I had a precisely defined goal, or it would have been hard to keep at it for so long.\\n\\nI wrote this new Lisp, called Bel, in itself in Arc. That may sound like a contradiction, but it's an indication of the sort of trickery I had to engage in to make this work. By means of an egregious collection of hacks I managed to make something close enough to an interpreter written in itself that could actually run. Not fast, but fast enough to test.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:1', text=\"\\n\\nI had to ban myself from writing essays during most of this time, or I'd never have finished. In late 2015 I spent 3 months writing essays, and when I went back to working on Bel I could barely understand the code. Not so much because it was badly written as because the problem is so convoluted. When you're working on an interpreter written in itself, it's hard to keep track of what's happening at what level, and errors can be practically encrypted by the time you get them.\\n\\nSo I said no more essays till Bel was done. But I told few people about Bel while I was working on it.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:2', text=' So for years it must have seemed that I was doing nothing, when in fact I was working harder than I\\'d ever worked on anything. Occasionally after wrestling for hours with some gruesome bug I\\'d check Twitter or HN and see someone asking \"Does Paul Graham still code?\"\\n\\nWorking on Bel was hard but satisfying. I worked on it so intensively that at any given time I had a decent chunk of the code in my head and could write more there. I remember taking the boys to the coast on a sunny day in 2015 and figuring out how to deal with some problem involving continuations while I watched them play in the tide pools.'), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:4', text=\" Like McCarthy's original Lisp, it's a spec rather than an implementation, although like McCarthy's Lisp it's a spec expressed as code.\\n\\nNow that I could write essays again, I wrote a bunch about topics I'd had stacked up. I kept writing essays through 2020, but I also started to think about other things I could work on. How should I choose what to do? Well, how had I chosen what to work on in the past? I wrote an essay for myself to answer that question, and I was surprised how long and messy the answer turned out to be. If this surprised me, who'd lived it, then I thought perhaps it would be interesting to other people, and encouraging to those with similarly messy lives.\"), Document(id='def37b99-8ff3-49d4-94d4-fc235e40454d:3', text=' It felt like I was doing life right. I remember that because I was slightly dismayed at how novel it felt. The good news is that I had more moments like this over the next few years.\\n\\nIn the summer of 2016 we moved to England. We wanted our kids to see what it was like living in another country, and since I was a British citizen by birth, that seemed the obvious choice. We only meant to stay for a year, but we liked it so much that we still live there. So most of Bel was written in England.\\n\\nIn the fall of 2019, Bel was finally finished.')]\n"
     ]
    }
   ],
   "source": [
    "queries = [\n",
    "    \"What did Paul Graham do growing up?\",\n",
    "    \"When and how did Paul Graham's mother die?\",\n",
    "    \"What, in Paul Graham's opinion, is the most distinctive thing about YC?\",\n",
    "    \"When and how did Paul Graham meet Jessica Livingston?\",\n",
    "    \"What is Bel, and when and where was it written?\",\n",
    "]\n",
    "for query in queries:\n",
    "    print(\"Query \")\n",
    "    print(\"=====\")\n",
    "    print(query)\n",
    "    print(\"Chat\")\n",
    "    response = chat_engine.chat(query)\n",
    "    print(\"Chat Response\")\n",
    "    print(\"========\")\n",
    "    print(response)\n",
    "    print(f\"Citations: {response.citations}\")\n",
    "    print(f\"Documents: {response.documents}\")\n",
    "    print(\"Async Chat\")\n",
    "    response = await chat_engine.achat(query)\n",
    "    print(\"Async Chat Response\")\n",
    "    print(\"========\")\n",
    "    print(response)\n",
    "    print(f\"Citations: {response.citations}\")\n",
    "    print(f\"Documents: {response.documents}\")\n",
    "    print(\"Stream Chat\")\n",
    "    response = chat_engine.stream_chat(query)\n",
    "    print(\"Stream Chat Response\")\n",
    "    print(\"========\")\n",
    "    response.print_response_stream()\n",
    "    print(f\"Citations: {response.citations}\")\n",
    "    print(f\"Documents: {response.documents}\")\n",
    "    print(\"Async Stream Chat\")\n",
    "    response = await chat_engine.astream_chat(query)\n",
    "    print(\"Async Stream Chat Response\")\n",
    "    print(\"========\")\n",
    "    await response.aprint_response_stream()\n",
    "    print(f\"Citations: {response.citations}\")\n",
    "    print(f\"Documents: {response.documents}\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can access the internals of the LlamaPack, including your Cohere LLM and your vector store index, via the `get_modules` method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'vector_index': <llama_index.packs.cohere_citation_chat.citations_context_chat_engine.VectorStoreIndexWithCitationsChat at 0x1748749d0>,\n",
       " 'llm': Cohere(callback_manager=<llama_index.core.callbacks.base.CallbackManager object at 0x176c55750>, system_prompt=None, messages_to_prompt=<function messages_to_prompt at 0x12f82b920>, completion_to_prompt=<function default_completion_to_prompt at 0x12f8e05e0>, output_parser=None, pydantic_program_mode=<PydanticProgramMode.DEFAULT: 'default'>, query_wrapper_prompt=None, model='command', temperature=0.5, max_retries=10, additional_kwargs={'prompt_truncation': 'AUTO'}, max_tokens=512)}"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "modules = cohere_citation_chat_pack.get_modules()\n",
    "display(modules)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llmapps",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
